const auth = require('../../utils/auth');

module.exports = async function (ctx, next){
    const token = ctx.headers['authorization']
    if(token !== undefined && token !== ""){
        const res = auth.verify(token);
        if(res.error == null){
            ctx.state[res.data.role] = res.data.data;
        }
    }
    await next();
}